<?php
declare (strict_types = 1);

namespace app\model;

use app\BaseModel;

/**
 * NoteDrawItem模型
 */
class NoteDrawItem extends BaseModel
{
    // 设置表名
    protected $name = 'note_draw_items';
    
    // 设置字段信息
    protected $schema = [
        'id'               => 'int',
        'draw_id'          => 'int',
        'note_id'          => 'int',
        'create_time'      => 'datetime',
    ];
    
    // 设置自动时间戳
    protected $autoWriteTimestamp = true;
    
    /**
     * 获取抽取记录
     */
    public function draw()
    {
        return $this->belongsTo(NoteDraw::class, 'draw_id', 'id');
    }
    
    /**
     * 获取纸条
     */
    public function note()
    {
        return $this->belongsTo(Note::class, 'note_id', 'id');
    }
} 